#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <error.h>
#include <errno.h>
#include <stdlib.h>

int main (int argc, char *argv[])
{
    int fd;
    mode_t mask=0;

    mask=umask(mask);
    printf("current mask: 0%o\n", mask);
    umask(mask);

    if ((fd = open("test.out", O_CREAT|O_RDWR, 
                    S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) < 0)
        error_at_line(EXIT_FAILURE, errno, __FILE__, __LINE__,
                "FATAL ERROR");

    exit(EXIT_SUCCESS);
}
